package com.sample.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.validator.Digits;
import org.hibernate.validator.NotNull;

@Entity
@Table(name="time_entry")
public class TimeEntry {
	@Id @GeneratedValue(strategy=GenerationType.AUTO) @Column(name="id", length=11, nullable=false)
	private Long id;
	
	@NotNull
	@Digits(integerDigits=2, fractionalDigits=2)
	@Column(scale=4, precision=2)
	private Double hours;
	
	@NotNull
	private Date date;
	
	@Digits(integerDigits=7, fractionalDigits=3)
	@Column(name="bill_rate", scale=10, precision=3)
	private Double billRate;
	
	@NotNull
	@ManyToOne(targetEntity=User.class, optional=false)
	@JoinColumn(name="user_id")
	private User user;
	
	@NotNull
	@ManyToOne(targetEntity=Project.class, optional=false)
	@JoinColumn(name="project_id")
	private Project project;
	
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public Double getHours() {
		return hours;
	}
	public void setHours(Double hours) {
		this.hours = hours;
	}
	public Date getDate() {
		return date;
	}
	public void setDate(Date date) {
		this.date = date;
	}
	public Double getBillRate() {
		return billRate;
	}
	public void setBillRate(Double billRate) {
		this.billRate = billRate;
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public Project getProject() {
		return project;
	}
	public void setProject(Project project) {
		this.project = project;
	}
}
